#include <bits/stdc++.h>
using namespace std;
class Tnode{
public:
    int data;
    Tnode* pLchild;
    Tnode* pRchild;
    Tnode(int d,Tnode* l = nullptr,Tnode* r = nullptr)
    {
        data = d;
        pLchild = l;
        pRchild = r;
    }
};
void BFS_Travel(Tnode* root)
{
    if(!root)
        return;
    else
    {
        queue<Tnode*> q;
        q.push(root);
        while(q.size())
        {
            Tnode* tmp = q.front();
            q.pop();
            cout<<tmp->data<<" ";
            if(tmp->pLchild!=nullptr)
                q.push(tmp->pLchild);
            if(tmp->pRchild!=nullptr)
                q.push(tmp->pRchild);
        }
    }
}
int main() {
    Tnode* A = new Tnode(8);
    Tnode* B = new Tnode(6);
    Tnode* C = new Tnode(10);
    Tnode* D = new Tnode(5);
    Tnode* E = new Tnode(7);
    Tnode* F = new Tnode(9);
    Tnode* G = new Tnode(11);
    A->pLchild = B;
    A->pRchild = C;
    B->pLchild = D;
    B->pRchild = E;
    C->pLchild = F;
    C->pRchild = G;
    BFS_Travel(A);
    delete A,B,C,D,E,F,G;
    return 0;
}